import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

@SuppressWarnings("serial")
public class AWTCard extends JFrame implements ActionListener {
    CardLayout card = new CardLayout();
    Container c = getContentPane();

    @SuppressWarnings("deprecation")
    public AWTCard() {
        super("卡片布局实例");
        JButton cb[] = new JButton[6];
        c.setLayout(card);
        for (int i = 0; i < 6; i++) {
            cb[i] = new JButton("卡片号为：" + i);
            cb[i].addActionListener(this);
            c.add(String.valueOf(i), cb[i]);
        }
        card.show(c, String.valueOf(0));
        setSize(400, 400);
        show(); // 显示窗口界面
    }

    public void actionPerformed(ActionEvent e) {
        card.next(c);
    }

    public static void main(String[] args) {
        new AWTCard();
    }
}
